package com.eaoa.uc.bustransfer.bo;

import com.eaoa.base.EABaseBusinessObject;
import com.eaoa.constants.BusOrderConstants;
import com.eaoa.dao.bus.BusOrderDAO;
import com.eaoa.vo.bus.BusOrder;
import com.eaoa.vo.bus.BusTransfer;

public class BusTransferAlterOrdersBO extends EABaseBusinessObject{
	
	public static String OPER_ADD="ADD";
	public static String OPER_REMOVE="REMOVE";
	
	private static BusOrderDAO orderDAO = new BusOrderDAO();
	private Long transferno;
	private Long orderno;
	private String operType;
	
	public BusTransferAlterOrdersBO(Long transferno, Long orderno, String operType) {
		super();
		this.transferno=transferno;
		this.orderno=orderno;
		this.operType=operType;
	}
	
	
	protected void performBusinessLogic() {
		BusOrder order =  (BusOrder)orderDAO.loadAndLock(orderno);
		
		BusTransfer transfer = new BusTransfer(transferno);
		if(operType.equals(OPER_ADD)){
			order.setBusTransfer(transfer);
			order.setIstransfer("Y");
		}else if(operType.equals(OPER_REMOVE)){
			order.setBusTransfer(null);
			order.setIstransfer("N");
		}
		orderDAO.update(order);
		

	}
}
